import Vue from 'vue';
import Router from 'vue-router';
import Transition from '../views/transition.vue';
let routes = [
    {
        path: '/',
        name: 'index',
        redirect: '/home'
    },
    {
        path: '/',
        component: Transition,
        children: [
            {
                path: 'home',
                name: 'home',
                component: resolve => require.ensure([], () => resolve(require('./../views/home/index.vue')), 'home'),    
                meta: {
                    title: '首页'
                },
            },
            {
                path: 'work',
                name: 'work',
                component: () => import('./../views/work/index.vue'),
                meta: {
                    title: '工作动态'
                },
            },
            {
                path: 'list',
                name: 'list',
                component: () => import('./../views/list/index.vue'),
                meta: {
                    title: '榜单发布'
                },
            },
            {
                path: '/evaluate',
                name: 'evaluate',
                component: () => import('./../views/evaluate/index.vue'),
                meta: {
                    title: '评价介绍'
                },
            },
            {
                path: '/we',
                name: 'we',
                component: () => import('./../views/we/index.vue'),
                meta: {
                    title: '关于我们'
                },
            },
            {
                path: '/details',
                name: 'details',
                component: () => import('./../views/details/index.vue'),
                meta: {
                    title: '新闻中心'
                },
            }
        ]
    }
]

let router = new Router({
    routes,
    scrollBehavior: () => ({
        y: 0
    }),
    mode: 'hash',
    // base: config.BASE_URL
});
/*
router.beforeEach((to, from, next) => {
    if (to.matched.length === 0) {
        // 如果匹配到的路由形如 https://172.24.1.117/?id=xxx&name=xxx，表明是关联跳转时没有权限，跳转到403
        next({ path: '/403' });
    } else {
        next();
    }
});
 */
Vue.use(Router);
export default router;